import { ajax } from "./util.js"
//获取账号、密码、按钮、盒子
let btn = document.querySelector("button")
let userInt = document.getElementsByName("username")
let pwdInt = document.getElementsByName("pwd")
let tip = document.querySelector(".tip")
btn.onclick = () => {
    ajax.post("http://localhost/register", { username: userInt[0].value, pwd: pwdInt[0].value }, (data) => {
        if (data.code === 200) {
            //注册成功
            tip.innerHTML = `注册成功！去<a href="/">登录</a>`
        } else {
            // 注册失败
            tip.innerHTML = data.msg;
        }
    })
}